<template>
    <el-upload drag :action="uploadImageAction" multiple :headers="{
        token
    }" name="img" :data="data" :on-success="uploadSuccess" :on-error="uploadError">
        <el-icon class="el-icon--upload">
            <upload-filled />
        </el-icon>
        <div class="el-upload__text">
            Drop file here or <em>click to upload</em>
        </div>
        <template #tip>
            <div class="el-upload__tip">
                jpg/png files with a size less than 500kb
            </div>
        </template>
    </el-upload>
</template>

<script setup>
import { getToken } from "@/utils/auth"
import { uploadImageAction } from '@/api/image'
const token = getToken()

defineProps({
    data: Object
})

const emit = defineEmits(["error", "success"])

const uploadSuccess = (response) => {
    emit("success", { response })
}
const uploadError = () => {
    emit("error", {})

}



</script>